Skip to content

fix: resolve symlinks before containment and reject device names and control characters - #717

Merged
ffumero2003 merged 2 commits into
masterfrom
fix-python-low-audit-path-validation
Nov 21, 2026
Merged

ffumero2003 merged 2 commits into
masterfrom
fix-python-low-audit-path-validation

Conversation

@ffumero2003

Copy link
Copy Markdown
Contributor

Context

Local path containment was checked lexically, allowing a symlink to resolve outside the root. Windows device names and alternate stream separators were accepted as local paths, and ASCII control characters below DEL were accepted in B2 file names.

Changes

  • Compare resolved root and target paths before accepting a local path, including paths with missing final components. Paths through symlinks outside the root now raise UnsupportedFilename; symlinked roots and internal links remain supported.
  • Reject Windows device-name components and stream separators on Windows, and reject ASCII control characters in B2 file names.
  • Add regression coverage and update scan fixtures for the changed containment behavior.

Verification

  • RED: tests for an escaping symlink, Windows CON and file:stream, and ASCII control character 1 failed against the corresponding unchanged master code before each fix.
  • Focused scan and filename tests: 96 passed, 2 skipped. Device/inode collision regression also passed with an in-root target.
  • Four API unit suites passed (v3, v2, v1, v0; existing skips and expected failures remain).
  • Ruff lint and changed-file formatting, git diff --check, and towncrier validation passed.
  • Master CI was already failing: static tests for previously fixed C30 and C59 are strict XPASS. The repository-wide Ruff format check also flags unchanged noxfile.py.

Containment is checked at path validation time; concurrent filesystem changes after the check remain possible. Windows-specific validation was tested using simulated platform selection on macOS; native Windows CI provides the platform check.

Refs #711

@ffumero2003 ffumero2003 self-assigned this Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 53f32b1c-caeb-4865-b7c4-b52dae84609c
Commits

Reviewing files that changed from the base of the PR and between be0814d and 6df0efc.

Files selected for processing: 9

  • b2sdk/_internal/scan/folder.py
  • b2sdk/_internal/utils/__init__.py
  • b2sdk/_internal/utils/filesystem.py
  • changelog.d/+path-validation.fixed.md
  • test/unit/scan/test_folder.py
  • test/unit/scan/test_folder_traversal.py
  • test/unit/scan/test_symlink_device_inode.py
  • test/unit/utils/test_filename_controls.py
  • test/unit/utils/test_filesystem.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@ffumero2003
ffumero2003 merged commit b5919e2 into master Nov 21, 2026
24 of 29 checks passed
@ffumero2003
ffumero2003 deleted the fix-python-low-audit-path-validation branch November 21, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant